<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

	<ui:composition template="/templates/template-menu.xhtml">
	
		<ui:define name="scripts">
		
			<script type="text/javascript">
						function inibir(){
							jQuery("#id-cargo").bind("keypress",function(e){
								e.preventDefault();
							});
						}
			</script>
			
			<style type="text/css">
				.rich-messages-label{
					font-weight:bold;
				}
			</style>
	</ui:define>

	<ui:define name="body">
		<rich:panel style="800px;">
	
			<f:facet name="header">
				<h:outputLabel value="Input de Pedidos" style="FONT-SIZE: small; FONT-FAMILY: 'SansSerif';"/>
			</f:facet>
	
			<h:form id="formulario-input" prependId="false">
	
				<h:panelGrid columns="4" style="width:50%">
					
					<rich:panel style="width:100%">
					
						<f:facet name="header">
							<h:outputText value="Dados do Cliente" style="FONT-SIZE: small; FONT-FAMILY: 'SansSerif';"/>
						</f:facet>
						
						<h:selectOneMenu id="cliente" value="#{vendaController.idCliente}" style="width:100%">
								
								<f:selectItem itemValue="#{0}" itemLabel="Selecione..." />
								
								<f:selectItems value="#{clienteController.listaCliente}" />
								
						</h:selectOneMenu>						
					</rich:panel>
					
					<rich:spacer width="10px"/>
				
					<rich:panel style="width:100%">
					
						<f:facet name="header">
							<h:outputText value="Dados do Consultor" style="FONT-SIZE: small; FONT-FAMILY: 'SansSerif';"/>
						</f:facet>
						
						<h:selectOneMenu id="consultor" value="#{vendaController.idFuncionario}" style="width:100%">
								
								<f:selectItem itemValue="#{0}" itemLabel="Selecione..." />
								
								<f:selectItems value="#{funcionarioController.listaFuncionario}" />
								
						</h:selectOneMenu>						
						
					</rich:panel>
					
				</h:panelGrid>
				
				<rich:spacer width="100%" height="5px"/>
				
				
				<a4j:commandButton value="Inserir item" onclick="Richfaces.showModalPanel('modal');" style="FONT-SIZE: medium; FONT-FAMILY: 'SansSerif';"/>
				
				<h:commandButton value="Salvar" actionListener="#{vendaController.salvar}" style="FONT-SIZE: medium; FONT-FAMILY: 'SansSerif';"/>
				
				<h:commandButton value="Limpar" action="#{itensController.limparItens}" style="FONT-SIZE: medium; FONT-FAMILY: 'SansSerif';"/>
					
				<rich:messages>
					 <f:facet name="errorMarker">
            			<h:graphicImage url="/imagens/alerta.png"/>
     				 </f:facet>

      				<f:facet name="infoMarker">
			            <h:graphicImage url="/imagens/ok.png"/>
				    </f:facet>
				</rich:messages>
					
				</h:form>
				<rich:spacer width="100%" height="5px"/>
				
				<rich:panel style="width:100%;">
					<f:facet name="header">
						<h:outputText value="Produtos" />
					</f:facet>
				
					<a4j:form id="formulario-tabela" prependId="false" >
						<rich:dataTable id="tabela" value="#{itensController.lista}" var="item" style="width:100%;"
						rowKeyVar="linha">
						
						<rich:column width="150">
							<f:facet name="header">
								<h:outputLabel value="ID Temporário" />
							</f:facet>
	
							<div id="div-produto" align="center">
								<h:outputLabel value="#{item.idItens}" />
							</div>
						</rich:column>	
	
						<rich:column width="150">
							<f:facet name="header">
								<h:outputLabel value="Descrição do produto" />
							</f:facet>
	
							<div id="div-produto" align="center">
								<h:outputLabel value="#{item.produto}" />
							</div>
						</rich:column>
	
						<rich:column width="50">
							<f:facet name="header">
								<h:outputLabel value="Status" />
				    		</f:facet>
	
							<div id="div-status" align="center">
								<h:outputLabel value="#{item.situacao}" />
							</div>
							
						</rich:column>
						
						<rich:column width="50">
							<f:facet name="header">
								<h:outputLabel value="Número SA3" />
							</f:facet>
							<div id="div-status" align="center">
								<h:outputLabel value="#{item.numeroSA3}" />
							</div>
						</rich:column>
						
						<rich:column width="50">
							<f:facet name="header">
								<h:outputLabel value="Número Siebel" />
							</f:facet>
							
							<div id="div-status" align="center">
								
	
								<h:outputLabel value="#{item.numeroSiebel}" />
							</div>
						</rich:column>
						
						<rich:column width="50">
							<f:facet name="header">
								<h:outputLabel value="Número OI B2B" />
							</f:facet>
							
							<div id="div-status" align="center">
								
	
								<h:outputLabel value="#{item.numeroOIB2B}" />
							</div>
						</rich:column>
						
						<rich:column width="50">
							<f:facet name="header">
								<h:outputLabel value="Número da OS" />
							</f:facet>
	
							<div id="div-status" align="center">
								<h:outputLabel value="#{item.numeroOS}" />
							</div>
						</rich:column>
						
						<rich:column width="50">
							<f:facet name="header">
								<h:outputLabel value="Fidelidade" />
							</f:facet>
							
							<div id="div-status" align="center">
								<h:outputLabel value="#{item.fidelidade}" />
							</div>
						</rich:column>
						
						<rich:column width="50">
							<f:facet name="header">
								<h:outputLabel value="Prazo da Fidelidade" />
							</f:facet>
							<div id="div-status" align="center">
								<h:outputLabel value="#{item.prazo}" />
							</div>
						</rich:column>
						
						<rich:column>
							<f:facet name="header">
								<h:outputLabel value="Ações" />
							</f:facet>
							
							<div align="center">
								<a4j:commandButton value="Excluir" image="/imagens/delete.png" actionListener="#{itensController.removerItem}"
								oncomplete="jQuery('#formulario-input').submit();">
									<f:setPropertyActionListener target="#{itensController.item.idItens}" value="#{item.idItens}" />
								</a4j:commandButton>
							</div>
						</rich:column>
					</rich:dataTable>
				  </a4j:form>
				</rich:panel>

		</rich:panel>
	
			
		<rich:modalPanel id="modal" width="565" height="230">
			<f:facet name="header">
				<h:outputText value="Adicionar Item" />
			</f:facet>
			
			<f:facet name="controls">
				<h:outputLabel value="X" onclick="Richfaces.hideModalPanel('modal');" />
			</f:facet>
		
		
			<a4j:form id="form-modal">
				
				<h:panelGrid columns="3">
					
					<h:panelGroup>
						
						<h:outputLabel value="Produto: " />
						
						<h:selectOneMenu id="produto-item" value="#{itensController.item.produto}">
							
							<f:selectItem itemValue="#{0}" itemLabel="Selecione..." />
								
							<f:selectItems value="#{produtoController.listaProduto}" />
								
						</h:selectOneMenu>
					</h:panelGroup>
					
					<h:panelGroup>
						<h:panelGrid>
							<h:outputLabel value="Status: " />
							<h:selectOneMenu id="situacao-item" style="width:150px;" value="#{itensController.item.situacao}">
			           			<f:selectItem itemValue="#{0}" itemLabel="Selecione..." />
			        			<f:selectItem itemLabel="Aguardando redirecionamento" itemValue="Aguardando redirecionamento"/>
			           			<f:selectItem itemLabel="Cadastro/Pedido Enviado" itemValue="Cadastro/Pedido Enviado"/>
			           			<f:selectItem itemLabel="Negócio Ganho" itemValue="Negócio Ganho"/>
			         			<f:selectItem itemLabel="Documentação Pendente" itemValue="Documentação Pendente"/>
			         			<f:selectItem itemLabel="Crédito Negado SA3" itemValue="Crédito Negado SA3"/>
			         			<f:selectItem itemLabel="Cancelado" itemValue="Cancelado"/>
			         			<f:selectItem itemLabel="Crédito Negado SIEBEL" itemValue="Crédito Negado SIEBEL"/>
			         			<f:selectItem itemLabel="Ativando Linhas" itemValue="Ativando Linhas"/>
			         			<f:selectItem itemLabel="Mercadoria em Rota" itemValue="Mercadoria em Rota"/>
			         			<f:selectItem itemLabel="Aguardando Portabilidade" itemValue="Aguardando Portabilidade"/>
			         			<f:selectItem itemLabel="Concluído" itemValue="Concluído"/>
			         			<f:selectItem itemLabel="Ativo" itemValue="Ativo"/>
			         			<f:selectItem itemLabel="Concluído c/ Devolução" itemValue="Concluído c/ Devolução"/>      			
			 		       	</h:selectOneMenu>
		 		       	</h:panelGrid>
	 		       	</h:panelGroup>
	 		       	
	 		       	<h:panelGroup>
	 		       		<h:panelGrid>
	 		       			<h:outputLabel value="Número SA3: " for="numero-sa3-item"/>
							<h:inputText id="numero-sa3-item" style="width:150px;" value="#{itensController.item.numeroSA3}"/>
						</h:panelGrid>
	 		       	</h:panelGroup>
 		       	</h:panelGrid>
 		       	
 		       	<h:panelGrid columns="3">
 		       		<h:panelGroup>
 		       			<h:panelGrid>
 							<h:outputLabel value="Número Siebel: " />
							<h:inputText id="numero-siebel-item" style="width:150px;" value="#{itensController.item.numeroSiebel}"/>
						</h:panelGrid>		       		
 		       		</h:panelGroup>
 		       	
 		       		<h:panelGroup>
 		       			<h:panelGrid>
 		       				<h:outputLabel value="Número Oi B2b: " />
							<h:inputText id="numero-oib2b-item" style="width:150px;" value="#{itensController.item.numeroOIB2B}"/>
						</h:panelGrid>
					</h:panelGroup>
 		       		
 		       		<h:panelGroup>
 		       			<h:panelGrid>
 		       				<h:outputLabel value="Número OS: " />
							<h:inputText id="numero-os-item" style="width:150px;" value="#{itensController.item.numeroOS}"/>
						</h:panelGrid>		
					</h:panelGroup>
 		       	</h:panelGrid>
				
				<h:panelGrid columns="2">
					<h:panelGroup>
						<h:panelGrid>
							<h:outputLabel value="Fidelidade: " />
							<h:selectOneMenu id="fidelidade-item" style="width:150px;" value="#{itensController.item.fidelidade}">
			           			<f:selectItem itemValue="#{0}" itemLabel="Selecione..." />
			           			<f:selectItem itemValue="Sim" itemLabel="Sim" />
			           			<f:selectItem itemValue="Não" itemLabel="Não" />		
			           		</h:selectOneMenu>
		           		</h:panelGrid>
					</h:panelGroup>
					
					<h:panelGroup>
						<h:panelGrid>
							<h:outputLabel value="Prazo: " />
							<h:selectOneMenu id="prazo-item" style="width:150px;" value="#{itensController.item.prazo}">
			           			<f:selectItem itemValue="#{0}" itemLabel="Selecione..." />
			           			<f:selectItem itemValue="12 meses" itemLabel="12 meses" />
			           			<f:selectItem itemValue="24 meses" itemLabel="24 meses" />
			           			<f:selectItem itemValue="36 meses" itemLabel="36 meses" />		
			           		</h:selectOneMenu>
		           		</h:panelGrid>
		         	</h:panelGroup>
		         	
				</h:panelGrid>
				
				<h:panelGrid>
		       	 	<a4j:commandButton value="Incluir item" style="padding-left:15px;" actionListener="#{itensController.adicionarItem}"
		       	 	oncomplete="jQuery('#formulario-input').submit();Richfaces.hideModalPanel('modal');"/>
				</h:panelGrid>
				
				<rich:spacer width="100%" height="5px"/>
		   		
			</a4j:form>
		</rich:modalPanel>
	</ui:define>
	
	</ui:composition>
</html>
